package com.hanggold.timer;

import io.netty.util.HashedWheelTimer;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * 时间轮标识.
 *
 * @author <a href="mailto:sunmch@163.com">smc</a>
 * @date 2021-11-24 10:27
 * @since 1.0.0
 **/
@Slf4j
public class HashedWheelTimerDemo {
    
    public static void main(String[] args) {
        log.info("nanoTime {} , milli {}", System.nanoTime(), System.currentTimeMillis());
        HashedWheelTimer hashedWheelTimer = new HashedWheelTimer(1L, TimeUnit.SECONDS, 10);
        hashedWheelTimer.newTimeout(timeout -> {
            log.info("timeout  {} start run", timeout);
            timeout.timer().newTimeout(timeout1 -> {
                log.info("timeout-child  {} start run", timeout);
            },1000,TimeUnit.MILLISECONDS);
            
        }, 2000, TimeUnit.MILLISECONDS);

//        hashedWheelTimer.newTimeout(timeout -> {
//            log.info("timeout2  {} start run", timeout);
//        }, 5000, TimeUnit.MILLISECONDS);
        
    }
}
